1 <?
2 echo $_SESSION[
"session_message"];
3 $_SESSION[
"session_message"] = "";
4 $MAXPAGE=
20;
5 ?>
6 <table height=
"28" cellSpacing="0" cellPadding="0" width="100%" border="0">
7       <tr align=center>
8         <td
class="title" width="100%">Danh sách &#7843;n ph&#7849;m bán chạy
9     </td>
10       </tr>
11     </table>
12 <?
13     
switch ($_GET['action'])
14     {
15         
case 'del' :
16             $id = $_GET[
'id'];
17             $pro=GetProductInfo($id);
18             
if ($pro)
19             {
20                 $sql =
"delete from products where id='".$id."'";
21                 $result = mysql_query($sql,$con);
22                 
if ($result)
23                 {
24                     
if (file_exists($pro['image'])) unlink($pro['image']);
25                     
if (file_exists($pro['image_large'])) unlink($pro['image_large']);
26
27                     echo
"<p align=center class='err'>&#272;ã xóa thành công</p>";
28                 }
29                     
else echo "<p align=center class='err'>Không th&#7875; xóa d&#7919; li&#7879;u</p>";
30             }
31             
break;
32     }
33 ?>
34
35 <?
36     
if (isset($_POST['ButDel'])) {
37         $cnt=
0;
38         
foreach ($_POST['chk'] as $id)
39         {
40             $pro=GetProductInfo($id);
41             
if ($pro)
42             {
43                 @$result = mysql_query(
"delete from products where id='".$id."'",$con);
44                 
if ($result) {
45                     $cnt++;
46                     
if (file_exists($pro['image'])) unlink($pro['products_image']);
47                     
if (file_exists($pro['image_large'])) unlink($pro['image_large']);
48
49                 }
50             }
51         }
52         echo
"<p align=center class='err'>&#272;ã xóa ".$cnt." ph&#7847;n t&#7917;</p>";
53     }
54     
if (isset($_POST['ButGood'])) {
55         $cnt=
0;
56         
foreach ($_POST['chk'] as $id)
57         {
58             $pro=GetProductInfo($id);
59             
if ($pro)
60             {
61                 
if (CountRecord("pro_good","products_id=".$pro['products_id'])<=0)
62                 {
63                     $result = mysql_query(
"insert into pro_good (products_id,language,pro_dateadded) values ('".$pro['products_id']."','".$pro['language']."',SYSDATE())",$con);
64                     
if ($result) {
65                         $cnt++;
66                     }
67                 }
68             }
69         }
70         echo
"<p align=center class='err'>&#272;ã c&#7853;p nh&#7853;t ".$cnt." ph&#7847;n t&#7917;</p>";
71     }
72     
if (isset($_POST['ButNew'])) {
73         $cnt=
0;
74         
foreach ($_POST['chk'] as $id)
75         {
76             $pro=GetProductInfo($id);
77             
if ($pro)
78             {
79                 
if (CountRecord("pro_new","products_id=".$pro['products_id'])<=0)
80                 {
81                     $result = mysql_query(
"insert into pro_new (products_id,language,pro_dateadded) values ('".$pro['products_id']."','".$pro['language']."',SYSDATE())",$con);
82                     
if ($result) {
83                         $cnt++;
84                     }
85                 }
86             }
87         }
88         echo
"<p align=center class='err'>&#272;ã c&#7853;p nh&#7853;t ".$cnt." ph&#7847;n t&#7917;</p>";
89     }
90     
if (isset($_POST['ButSaleoff'])) {
91         $cnt=
0;
92         
foreach ($_POST['chk'] as $id)
93         {
94             $pro=GetProductInfo($id);
95             
if ($pro)
96             {
97                 
if (CountRecord("pro_saleoff","products_id=".$pro['products_id'])<=0)
98                 {
99                     $result = mysql_query(
"insert into pro_saleoff (products_id,language,pro_dateadded) values ('".$pro['products_id']."','".$pro['language']."',SYSDATE())",$con);
100                     
if ($result) {
101                         $cnt++;
102                     }
103                 }
104             }
105         }
106         echo
"<p align=center class='err'>&#272;ã c&#7853;p nh&#7853;t ".$cnt." ph&#7847;n t&#7917;</p>";
107     }
108     
109     
if (isset($_POST['trogia'])) {
110         $cnt=
0;
111         
foreach ($_POST['chk'] as $id)
112         {
113             $pro=GetProductInfo($id);
114             
if ($pro)
115             {
116                 @$result = mysql_query(
"update products set trogia=1 where id='".$id."'",$con);
117                 
if ($result) {
118                     $cnt++;
119
120                 }
121             }
122         }
123         echo
"<p align=center class='err'>Đã thêm ".$cnt." sản phẩm trợ giá</p>";
124     }
125     
126         
if (isset($_POST['huytrogia'])) {
127         $cnt=
0;
128         
foreach ($_POST['chk'] as $id)
129         {
130             $pro=GetProductInfo($id);
131             
if ($pro)
132             {
133                 @$result = mysql_query(
"update products set trogia=0 where id='".$id."'",$con);
134                 
if ($result) {
135                     $cnt++;
136
137                 }
138             }
139         }
140         echo
"<p align=center class='err'>Đã hủy ".$cnt." sản phẩm trợ giá</p>";
141     }
142     
143     
144     
145
146
147 ?>
148
149 <?
150     $page = $_GET[
"page"];
151     $p=
0;
152     
if ($page!='') $p=$page;
153     $
where="1=1";
154     
//if ($_REQUEST['status']!='') $where="products_status=".$_REQUEST['status']." ";
155     
if ($_REQUEST['cat']!='') $where="cat=".$_REQUEST['cat'];
156 ?>
157 <form method=
"POST" name="frmList" action="index.php">
158 <input type=hidden name=
"page" value="<? echo $page; ?>">
159 <?
160 function taotrang($total,$link,$nitem,$itemcurrent,$step=
10)
161 {
global $con;
162     $ret=
"";
163     
164     $param=
"";
165     $pages=count_page($total,$nitem);
166     
if ($itemcurrent>0) $ret.='<a title="&#272;&#7847;u tiên" href="'.$link.'0" class="lslink">[&lt;]</a> ';
167     
if ($itemcurrent>1) $ret.='<a title="V&#7873; tr&#432;&#7899;c" href="'.$link.($itemcurrent-1).'" class="lslink">[&lt;&lt;]</a> ';
168     $
from=($itemcurrent-$step>0?$itemcurrent-$step:0);
169     $to=($itemcurrent+$step<$pages?$itemcurrent+$step:$pages);
170     
for ($i=$from;$i<$to;$i++)
171     {
172         
if ($i!=$itemcurrent) $ret.='<a href="'.$link.$i.'" class="lslink">'.($i+1).'</a> ';
173         
else $ret.='<b>'.($i+1).'</b> ';
174     }
175     
if (($itemcurrent<$pages-2) && ($pages>1)) $ret.='<a title="Ti&#7871;p theo" href="'.$link.($itemcurrent+1).'">[&gt;&gt;]</a> ';
176     
if ($itemcurrent<$pages-1) $ret.='<a title="Cu&#7889;i cùng" href="'.$link.($pages-1).'">[&gt;]</a>';
177     
return $ret;
178 }
179
180     $pageindex=taotrang(CountRecord(
"products",$where),"./?act=product&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
181 ?>
182
183 <table cellspacing=
"0" cellpadding="0" width="100%">
184 <?
if ($_REQUEST['code']==1) echo '<tr><td colspan="2" align="center" class="err">&#272;ã c&#7853;p nh&#7853;t thành công</td></tr>'; ?>
185 <tr>
186 <td
class="smallfont">Trang : <? echo $pageindex; ?></td>
187 <td height=
"30" align="right" class="smallfont">
188     <
select size="1" name="ddCat" class="smallfont">
189 <?
190     $ms=GetListCat(
17);
191     echo
'<option value="">[T&#7845;t c&#7843;]</option>';
192     
foreach ($ms as $m)
193         
if ($m[0]!=$_REQUEST['cat'])
194             echo
'<option value="'.$m[0].'">'.$m[1].'</option>';
195         
else
196             echo
'<option selected value="'.$m[0].'">'.$m[1].'</option>';
197 ?>
198     </
select>
199     <input type=
"button" value="Chuy&#7875;n" class="button" onclick="window.location='./?act=product&cat='+ddCat.value">
200     </td>
201 </tr>
202 </table>
203
204 <table border=
"1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
205   <tr>
206     <td align=center nowrap
class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
207     <td colspan=
"2" nowrap class="title">&nbsp;</td>
208     <td align=
"center" nowrap class="title"><b>ID</b></td>
209        <td align=
"center" nowrap class="title"><b>Mã </b></td>
210      <td align=
"center" nowrap class="title"><b>Tên </b></td>
211     <td align=
"center" nowrap class="title"><b>Hình nh&#7887;</b></td>
212     <td align=
"center" nowrap class="title"><b>Người đăng</b></td>
213
214     <td align=
"center" nowrap class="title"><b>Th&#7913; t&#7921;</b></td>
215     <td align=
"center" nowrap class="title"><b>Danh m&#7909;c thành viên</b></td>
216 <td align=
"center" nowrap class="title"><b>Danh m&#7909;c hệ thống</b></td>
217 <td align=
"center" nowrap class="title"><b>Trợ giá</b></td>
218 <td align=
"center" nowrap class="title"><b>Ngày đăng</b></td>
219
220   </tr>
221   
222   <?php
223             $sql=
"select * from products where $where and cat_mem!=45 and cat_mem!=46 and new=2 order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
224             $result=mysql_query($sql,$con);
225             $i=
0;
226             
while(($row=mysql_fetch_array($result)))
227             {
228             $i++;
229             
if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
230             $catinfo=GetCategoryInfo($row[
'cat_mem']);
231             $cat_system=GetCatInfo($row[
'cat']);
232             $providerinfo=GetProviderInfo($row[
'providers_id']);
233             $donvi=GetDonviInfo($row[
'donvi_id']);
234   ?>
235   
236   <tr>
237     <td align=
"center" bgcolor="<? echo $color; ?>" class="smallfont">
238     <input type=
"checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
239     <td align=
"center" bgcolor="<? echo $color; ?>" class="smallfont">
240     <a href=
"./?act=product_m&cat=<? echo $_REQUEST['cat']; ?>&status=<? echo $_REQUEST['status']; ?>&id=<? echo $row['id']; ?>&page=<? echo $page?>">S&#7917;a</a></td>
241     <td align=
"center" bgcolor="<? echo $color; ?>" class="smallfont">
242     <a onclick=
"return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" href="./?act=product&action=del&cat=<? echo $_REQUEST['cat']; ?>&status=<? echo $_REQUEST['status']; ?>&id=<? echo $row['id']; ?>">Xoá</a></td>
243     <td bgcolor=
"<? echo $color; ?>" align="left" align="left" class="smallfont"><? echo $row['id']; ?>&nbsp;</td>
244      <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['code']; ?>&nbsp;</td>
245     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?>&nbsp;</td>
246     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['image']; ?>&nbsp;</td>
247     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['user']; ?>&nbsp;</td>
248     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?>&nbsp;</td>
249     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $catinfo['name']; ?>&nbsp;</td>
250     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $cat_system['name']; ?>&nbsp;</td>
251     <td bgcolor=
"<? echo $color; ?>" class="smallfont">
252     <?
if($row['trogia']=='1')
253     {?>
254     <font color=
"blue"><b>Có</b></font>
255     <?}
else{?>
256     <font color=
"red"><b>Không</b></font>
257     <?}?>
258     </td>
259     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['date']; ?>&nbsp;</td>
260
261   </tr>
262   <?
263                 }
264   ?>
265 </table>
266 <input type=
"hidden" name="act" value="product"><table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
267     <tr>
268         <td>
269 <input type=
"submit" value="Xóa Ch&#7885;n" name="ButDel" onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" class="button"></td>
270         <td align=
"right">
271 <input type=
"submit" value="Sản phẩm trợ giá" name="trogia" class="button">
272 <input type=
"submit" value="Hủy sản phẩm trợ giá" name="huytrogia" class="button"></td>
273 <td align=
"right">
274 &nbsp;&nbsp;&nbsp;
275 </td>
276
277
278     </tr>
279 </table>
280 </form>
281 <script language=
"JavaScript">
282 function chkallClick(o) {
283     
var form = document.frmList;
284     
for (var i = 0; i < form.elements.length; i++) {
285         
if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
286             form.elements[i].
checked = document.frmList.chkall.checked;
287         }
288     }
289 }
290 </script>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.821 lượt xem

Gõ tìm kiếm nhanh...